import requests
from requests.auth import HTTPBasicAuth

# Azure DevOps Personal Access Token (PAT)
personal_access_token = "rohvxi4cveemyk2ttapc5whjn22ohjfmeabdds7xh4nn7ls7uctq"

# Azure DevOps organization URL
organization_url = "https://dev.azure.com/HKITDevOps"

# Project name
project_name = "HKWebApp"

# API endpoint for getting Git repositories
api_url = f"{organization_url}/{project_name}/_apis/git/repositories?api-version=6.1-preview.1"

# Set headers
headers = {
    "Authorization": f"Basic {personal_access_token}",
    "Content-Type": "application/json"
}

# Make the API request
response = requests.get(api_url, headers=headers)
print(api_url)
print("Response Status Code:", response.status_code)
print("Response Content:", response.content)

# Check if the request was successful
if response.status_code == 200:
    repositories = response.json()["value"]

    # Print repository names
    for repo in repositories:
        print(repo["name"])
else:
    print(f"Failed to retrieve repositories. Status code: {response.status_code}")
    print(response.text)